package com.base.commons.tools.filter;

import com.alibaba.fastjson.serializer.ValueFilter;
import com.base.commons.tools.utils.SensitiveInfoUtils;

import java.util.List;

/**
 * @author daiguoping
 * @version 1.00
 * @time 2020/3/12 0012
 * @description
 */
public class CreateOrderLogFilter implements ValueFilter {

    @Override
    public Object process(Object object, String name, Object value) {
        if (SensitiveInfoUtils.logFilterStr.containsKey(name)) {
            if (value instanceof String) {
                return SensitiveInfoUtils.logFilterStr.get(name).apply((String) value);
            }
        }
        if (SensitiveInfoUtils.logFilterList.containsKey(name)) {
            if (value instanceof List) {
                List<String> orderLabels = (List<String>) value;
                return SensitiveInfoUtils.logFilterList.get(name).apply(orderLabels);
            }
        }

        return value;
    }

}
